import axios from 'axios'

const request = axios.create({
	timeout: 5000
})


request.interceptors.request.use(config => {
	return config
}, error => {
	return Promise.reject(error)
})



request.interceptors.response.use(response => {
	const { code } = response.data
	if(code === 400) {
		console.log('请求客户端失败');
	}

	if(code === 404) {
		console.log('请求资源没有！！！');
	}

	if(code === 500) {
		console.log('服务器有问题');
	}


	return response
}, error => {
	return Promise.reject(error)
})

export default request